<?php

class SettingController extends Silk_Controller_Admin_Action {

    public function init(){
	parent::init();
	$this->appendBreadcrumbs(Silk::Translate('Configuration'), $this->resolveRoute('configuration'));
    }

    public function adminAction(){

	$this->initPaginatorParams('silk_cms_settings___', 'name');

	$session = Silk::getSession();

	if ($this->_request->has('criteria'))
	    $session->criteria = $this->_getParam('criteria');
	else
	    $session->criteria = null;

	$Settings = new Silk_Settings();

	$paginator = $Settings->getPaginator($session->criteria, $session->offset, $session->limit, "{$session->sort} {$session->order}");

	$paginator->setItemCountPerPage($session->limit);
	$paginator->setCurrentPageNumber($session->page);

	$this->view->settings = $paginator;

    }

    public function updateAction(){

	$Settings = new Silk_Settings();

	$settings = $this->_getParam('settings');

	if ($settings && count($settings) > 0){
	    foreach ($settings as $key => $val){
		$Settings->setValue($key, $val);
	    }
	}

	$this->gotoRoute('configuration');
    }
}

?>